package com.firefoxking.mysite.config;

import com.firefoxking.mysite.controller.interceptor.AdminInterceptor;
import com.firefoxking.mysite.controller.interceptor.AlphaInterceptor;
import com.firefoxking.mysite.controller.interceptor.BaseInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    @Autowired
    private AlphaInterceptor alphaInterceptor;

    @Autowired
    private BaseInterceptor baseInterceptor;

    @Autowired
    private AdminInterceptor adminInterceptor;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // registry.addInterceptor(alphaInterceptor).addPathPatterns("/**");
        registry.addInterceptor(baseInterceptor);
        registry.addInterceptor(adminInterceptor)
                .excludePathPatterns("/**/**/*.css", "/**/**/*.js", "/**/**/*.png", "/**/**/*.jpg", "/**/&&/*.jpeg", "/admin/login")
                .addPathPatterns("/admin/**");
    }
}
